package test.ui {
	import gear.core.Game;
	import gear.net.AssetData;
	import gear.net.LibData;
	import gear.net.RESManager;
	import gear.net.SWFLoader;
	import gear.ui.containers.GPanel;
	import gear.ui.containers.GTabbedPanel;
	import gear.ui.controls.GButton;
	import gear.ui.core.GAlign;
	import gear.ui.data.GButtonData;
	import gear.ui.data.GPanelData;
	import gear.ui.data.GTabbedPanelData;
	import gear.ui.manager.UIManager;

	import flash.events.Event;

	/**
	 * @version 20091215
	 * @author bright
	 */
	[SWF(width=1000,height=570,backgroundColor=0x003399,frameRate=30)]
	public class TestGPanel extends Game {
		private var _panel : GPanel;
		private var _panel2 : GPanel;
		private var _tabbedPanel : GTabbedPanel;

		override protected function startup() : void {
			RESManager.instance.add(new SWFLoader(new LibData("assets/ui.swf")));
			RESManager.instance.addEventListener(Event.COMPLETE, completeHandler);
			RESManager.instance.load();
		}

		private function completeHandler(event : Event) : void {
			addPanel();
			addTabbedPanel();
		}

		private function addPanel() : void {
			var data : GPanelData = new GPanelData();
			data.bgSkin = UIManager.getSkin(new AssetData("GTabbedPanel_bgSkin"));
			data.width = 149;
			data.height = 150 + 13;
			data.padding = 0;
			_panel = new GPanel(data);
			data = data.clone();
			_panel2 = new GPanel(data);
			var buttonData : GButtonData = new GButtonData();
			buttonData.x = 10;
			buttonData.y = 10;
			buttonData.labelData.text = "测试1";
			_panel.add(new GButton(buttonData));
			buttonData = buttonData.clone();
			buttonData.y = 50;
			buttonData.labelData.text = "测试2";
			_panel2.add(new GButton(buttonData));
		}

		private function addTabbedPanel() : void {
			var data : GTabbedPanelData = new GTabbedPanelData();
			data.x = 10;
			data.y = 10;
			data.align = GAlign.CENTER;
			_tabbedPanel = new GTabbedPanel(data);
			_tabbedPanel.addTab("合成", _panel);
			_tabbedPanel.addTab("转移", _panel2);
			_tabbedPanel.addTab("帽子", _panel);
			addChild(_tabbedPanel);
		}

		public function TestGPanel() {
			super();
		}
	}
}
